home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 5
/
The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO
/
amiga
/
dirsize.lha
/
DirSize.Doc
< prev
next >
Wrap
Text File
|
1994-01-30
|
6KB
|
145 lines
NAME
DirSize -- Report size informations on a directory tree (V37)
SYNOPSIS
DirSize DIR,P=PATTERN,BS=BLOCKSIZE/N,EXT=EXTENSION/N,ALL/S,LINKS/S
FUNCTION
Report the number of files and directories, along with the total
amount of bytes and blocks used, contained in a specified directory
(including, at your option, its subdirectories).
DirSize will not rely on DOS to calculate the block usage of a file:
instead, it will make it's own calculations based on the block size
and on the number of blocks which an extension block can keep track
of (refer to the AmigaDOS Manual for more informations on this);
these parameters can be entered on the command line (but have
reasonable defaults). In this way you can calculate what would be
the space required for a bunch of files in your RAM disk or FFS hard
disk once copied to floppy disk(s) (or vice-versa).
INPUTS
DIR - Name of the directory to read.
If omitted, DirSize will read the current directory.
P=PATTERN - File pattern to look for.
With this option you can specify which files you want to consider
(or to exclude).
This option does not affect directories; directories are always
included in the count.
BLOCKSIZE/N - Number of bytes contained in a data block.
Defaults to 512, the size of FFS data blocks.
This value is 512 for FFS volumes, 488 for OFS volumes, and 1024
for the 2.04 RAM disk. Other values are possible, but unlikely.
DirSize will not accept block sizes less than 8 (no upper limit).
EXTENSION/N - Number of block pointers in an extension block.
Defaults to 72, the correct value for both FFS and OFS.
This value is 72 for all known Amiga filesystems except the RAM
disk, which uses a different (and to me unknown) method to keep
track of the blocks belonging to a file. Set it to zero if you
want to calculate the number of blocks used in a RAM disk (pretty
useless operation, but if you want, you can).
ALL/S - Enter subdirectories recursively.
LINKS/S - Count hard links as if they were real directories (by
entering them recursively) or files (by adding their byte and
block size to the total).
By default a hard link, either to directory or file, will only
increment the block count (it does use space, so it's included in
the count; please tell me if you think it should be ignored),
without being entered if it is a directory, or being added to the
byte count if it is a file.
Soft links are not handled, mainly because nobody uses them (as
above, please tell me if you think they should be).
RESULT
'%ld files - %ld dirs - %ld bytes - %ld blocks'
I think the output is clear enough. Just for completeness, I'll say
that the byte count is simply a sum of the sizes of all files, and
doesn't take into account the extension blocks and the bytes which
could be left unused at the end of the last data block of a file.
The possible return codes are:
- RETURN_OK ( 0): all ok;
- RETURN_WARN ( 5): generic error reading directory;
- RETURN_ERROR (10): wrong arguments;
- RETURN_FAIL (20): no libraries or memory.
NOTES
A directory will always count as one block used. If you want to know
how many blocks your files are taking, just do (blocks - dirs).
DirSize is not pure, because it uses only one instance of DOSBase to
avoid strange tricks; but it's very unlikely that dos.library fails
to open, and it does always return the same address (no task-specific
data). So it is safe to make DirSize resident.
Don't worry about DirSize or other programs reporting one more block
used than Info reports: in certain conditions, which I wasn't able
to determine for sure (seems when the disk is more than 50% full),
Info (in fact, the omonymous DOS call it uses) reports that there is
one more block free than there really is, even when the disk is full.
I think this is a bug, or undocumented feature, of dos.library 37.44
(Kickstart 37.175).
EXAMPLES
DirSize Devel: *.c all
would count all my C source files, producing:
'266 files - 179 dirs - 1400769 bytes - 3318 blocks'
DirSize Work: ~(*.info)
would count the files and directories in the root of my hard
disk, excluding icons.
BUGS
I hope and think none serious enough to damage your computer, or even
to show up that blinking alert called guru.
Of course, I wish to hear about the bugs you might find.
FUTURE
Support patterns on protection bits, dates, etc. Ever needed to know
how many megabytes you had to backup, i.e. no 'a' bit set?
Use utility.library for 32-bit multiplies and divides (thus avoiding
the linking with sc.lib).
Ability to read the block size from the device (via Info()).
Multiple source directories.
DISTRIBUTION
This program is freeware. You may redistribute it as long as:
- this text and the source code are included;
- you don't charge more than a nominal copying fee for distribution.
Please state your modifications to the code with a clear comment, and
send me your modified version. It would be a good idea to include
the original code, anyway.
Any contribution will be greatly appreciated (I'm a poor engineering
student, you know).
DISCLAIMER
The author does not assume any responsibility for damages which could
result by the use of this program. The entire risk for the use of
this program is assumed by the user.
AUTHOR
Flavio Stanchina
Loc. Montevaccino, 39
38040 Trento (Italia)
email: 2:333/408.9@fidonet.org